﻿using System;


namespace DailyFx
{
	public static class Math2
	{
		//
		public static bool SloppyEquals ( decimal x, decimal y, decimal epsilon = 1.0e-6m )
		{
			return Math.Abs(x - y) < epsilon;
		}

		//
		public static decimal Max ( decimal x, decimal y, decimal z )
		{
			return Math.Max(Math.Max(x, y), z);
		}

		//
		public static decimal Min ( decimal x, decimal y, decimal z )
		{
			return Math.Min(Math.Min(x, y), z);
		}
		
		
		//
		public static decimal Chock ( decimal val, decimal low, decimal high )
		{
			return Math.Min ( Math.Max(val, low), high);
		}
		//
		public static int Chock ( int val, int low, int high )
		{
			return Math.Min(Math.Max(val, low), high);
		}

		//
        public static decimal Sqrt ( decimal x )
        {
            return (decimal)Math.Sqrt( (double)x );
        }

		//
		public static decimal Pow( decimal x, decimal n )
		{
			return (decimal)Math.Pow( (double)x, (double)n );
		}

		//
		public static decimal Exp ( decimal x )
		{
			return (decimal)Math.Exp( (double)x );
		}

		//
		public static decimal Hypot ( decimal x, decimal y )
		{
			return (decimal)Math.Sqrt(Math.Pow((double)x, 2) + Math.Pow((double)y, 2));
		}
		//
		public static decimal Sin ( decimal x )
		{
			return (decimal)Math.Sin( (double)x);
		}
		//
		public static decimal Cos ( decimal x )
		{
			return (decimal)Math.Cos((double)x);
		}
	}
}
